package com.fms.controller;

import com.fms.entity.Procurement;
import com.fms.result.ResultData;
import com.fms.service.ProcurementService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/procurement")
@RequiredArgsConstructor
public class ProcurementController {
    private final ProcurementService procurementService;

    //获取采购单
    @GetMapping("/getProcurement")
    public ResultData getProcurement(){
        ResultData resultData = procurementService.getProcurements();
        return resultData;
    }

    //添加板子采购单
    @PostMapping("/addBoardProcurement")
    public ResultData addBoardProcurement(@RequestBody Procurement procurement){
        System.out.println(procurement);
        ResultData resultData = procurementService.addOrEditBoardProcurement(procurement);
        return resultData;
    }

    //添加五金采购单
    @PostMapping("/addHardwareProcurement")
    public ResultData addHardwareProcurement(@RequestBody Procurement procurement){
        System.out.println(procurement);
        ResultData resultData = procurementService.addOrEditHardwareProcurement(procurement);
        return resultData;
    }

    //删除采购单
    @PostMapping("/deleteProcure/{id}")
    public ResultData deleteProcurement(@PathVariable("id") Long id){
        ResultData resultData = procurementService.deleteProcurementById(id);
        return resultData;
    }

    //流转采购单
    @PostMapping("/transferProcurement")
    public ResultData transferProcurement(@RequestBody Procurement procurement){
        ResultData resultData = procurementService.transferProcurement(procurement);
        return resultData;
    }

    //通过采购单
    @PostMapping("/denyProcurement")
    public ResultData passProcurement(@RequestBody Procurement procurement){
        System.out.println(procurement);
        ResultData resultData = procurementService.denyProcurement(procurement);
        return resultData;
    }

    //新增支付信息
    @PostMapping("/addProcurementPayment")
    public ResultData addPaymentProcurement(@RequestBody Procurement procurement){
        System.out.println(procurement);
        ResultData resultData = procurementService.addPaymentProcurement(procurement);
        return resultData;
    }

    //新增入库信息
    @PostMapping("/addWarehousingProcurement")
    public ResultData addWarehousingProcurement(@RequestBody Procurement procurement){
        System.out.println(procurement);
        ResultData resultData = procurementService.addWarehousingProcurement(procurement);
        return resultData;
    }
}
